# 实验1：使用unittest框架注册接口测试
import requests
import unittest


class RegisterTest(unittest.TestCase):
    def setUp(self):
        self.url = "http://129.211.129.101:9006/user/register.do"
        self.user_info = {
            "username": "lllljl",
            "password": "123456",
            "email": "lllljjj@qq.com",
            "phone": "13555555556",
            "question": "最喜欢的书",
            "answer": "阿衰"
        }

    def test_register(self):
        s = requests.session()
        res = s.post(self.url, data=self.user_info).json()
        self.assertIn("用户名已经存在", str(res))


if __name__ == '__main__':
    unittest.main()
